/*
 * @Description:检测计划相关接口
 * @Author: Rfan
 * @Date: 2022-10-14 10:24:12
 * @LastEditTime: 2022-10-20 20:15:08
 */

import request from '@/utils/request';
import type { IPageQuery } from '@/interfaces/global';
import { Key } from 'react';

/**
 * 检测方案
 */
// 分页查询档案条目参数
export interface IFetchDetectionListByPageParams {
  archiveTypeId?: number;
  atCode?: number;
  atType?: number;
  createTime?: string;
  detectionObjType?: number;
  id?: number;
  operator?: number;
  operatorName?: string;
  operatorTime?: string;
  schemeDesc?: string;
  schemeName?: string;
}
// 分页查询档案条目
export function fetchDetectionListByPage(data: IPageQuery<IFetchDetectionListByPageParams>) {
  return request({
    url: `/archive-detection-scheme/page/`,
    method: 'post',
    data
  });
}
// 查询档案条目
export function fetchDetectionList(data: IFetchDetectionListByPageParams) {
  return request({
    url: `/archive-detection-scheme/list/`,
    method: 'post',
    data
  });
}
// 添加检测方案参数类型
export interface IAddPlanParams {
  archiveTypeId: number;
  atCode: number;
  atType: number;
  detectionObjType: number;
  schemeName: string;
  schemeDesc?: string;
  remark?: string;
}
// 添加检测方案
export function addDetectionPlan(data: IAddPlanParams) {
  return request({
    url: `/archive-detection-scheme/`,
    method: 'post',
    data
  });
}

// 编辑检测方案参数类型
export interface IEditPlanParams extends IAddPlanParams {
  id: number;
}
// 编辑检测方案
export function editDetectionPlan(data: IEditPlanParams) {
  return request({
    url: `/archive-detection-scheme/`,
    method: 'put',
    data
  });
}

// 删除检测方案
export function deleteDetectionPlan(id: Key) {
  return request({
    url: `/archive-detection-scheme/${id}`,
    method: 'delete'
  });
}

/**
 * 检测规则
 */
// 查询档案条目列表参数
export interface IDetectionRuleListParams {
  archiveTypeId?: number;
  atCode?: number;
  atType?: number;
  createTime?: string;
  id?: number;
  operator?: number;
  operatorName?: string;
  operatorTime?: string;
  schemeId?: number;
}
// 查询档案条目列表
export function fetchDetectionRule(data: IDetectionRuleListParams) {
  return request({
    url: `/archive-detection-scheme-rule/list`,
    method: 'post',
    data
  });
}

// 查询档案条目列表类型
export interface IAddDetectionRuleParams {
  archiveTypeId: number;
  atCode: number;
  atType: number;
  detectionRuleJson: string;
  schemeId: number;
}
// 查询档案条目列表
export function addDetectionRule(data: IAddDetectionRuleParams) {
  return request({
    url: `/archive-detection-scheme-rule/`,
    method: 'post',
    data
  });
}

// 查询档案条目列表类型
export interface IEditDetectionRuleParams extends IAddDetectionRuleParams {
  id: number;
}
// 查询档案条目列表
export function editDetectionRule(data: IEditDetectionRuleParams) {
  return request({
    url: `/archive-detection-scheme-rule/`,
    method: 'put',
    data
  });
}
